<template>
	<view class="content">
		<yt-card head="店内开单" v-show="!ishouse_manage && !isexamine || isboss">
			<view class="opcation_list">
				<u-row :gutter="12">
					<u-col :span="3" text-align ="center">
						<yt-opcation-item
						icon="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-baf89db3-4d55-4b1f-a05e-c0a1170f8dce/3c450973-2273-4edc-9b1f-1c15c43a8c4e.png" 
						text="拍照上传"
						class="opcation_list_item"
						@click="intoComponent">
						</yt-opcation-item>
					</u-col>
				</u-row>
			</view>
		</yt-card>
		<yt-card head="仓库管理" v-show="ishouse_manage || isboss">
			<view class="opcation_list">
				<u-row :gutter="12">
					<u-col :span="3" text-align ="center">
						<yt-opcation-item
						icon="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-baf89db3-4d55-4b1f-a05e-c0a1170f8dce/d98dbdbb-0291-406a-a84b-a6b4fc439b8e.png" 
						text="扫码入库"
						class="opcation_list_item"
						@click="intoComponent">
						</yt-opcation-item>
					</u-col>
					<u-col :span="3" text-align ="center">
						<yt-opcation-item
						icon="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-baf89db3-4d55-4b1f-a05e-c0a1170f8dce/5cd0fcf5-e7f4-4899-92f3-d523d8ebfdd8.png" 
						text="手动入库"
						class="opcation_list_item"
						@click="intoComponent">
						</yt-opcation-item>
					</u-col>
					<u-col :span="3" text-align ="center">
						<yt-opcation-item
						icon="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-baf89db3-4d55-4b1f-a05e-c0a1170f8dce/4d3216c3-1261-4e59-aed2-9c8463659287.png" 
						text="出库审批"
						class="opcation_list_item"
						@click="intoComponent">
						</yt-opcation-item>
					</u-col>
				</u-row>
			</view>
		</yt-card>
		<yt-card head="仓库详情" v-show="ishouse_manage || isboss">
			<view class="opcation_list">
				<u-row :gutter="12">
					<u-col :span="3" text-align ="center">
						<yt-opcation-item
						icon="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-baf89db3-4d55-4b1f-a05e-c0a1170f8dce/3285ef3d-3549-45ec-80b4-4ef847bcb5ab.png" 
						text="库存查看"
						class="opcation_list_item"
						@click="intoComponent">
						</yt-opcation-item>
					</u-col>
					<u-col :span="3" text-align ="center">
						<yt-opcation-item
						icon="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-baf89db3-4d55-4b1f-a05e-c0a1170f8dce/62964979-63e3-4f1e-8ba5-1facd787910a.png" 
						text="出库记录"
						class="opcation_list_item"
						@click="intoComponent">
						</yt-opcation-item>
					</u-col>
					<u-col :span="3" text-align ="center">
						<yt-opcation-item
						icon="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-baf89db3-4d55-4b1f-a05e-c0a1170f8dce/1ba5c4c9-d5b3-4d67-a59c-096e3ea1887f.png" 
						text="产品转库"
						class="opcation_list_item"
						@click="intoComponent">
						</yt-opcation-item>
					</u-col>
				</u-row>
			</view>
		</yt-card>
		<yt-tabbar></yt-tabbar>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import ytTabbar from '../../comment/yt-tabbar.vue'
	import ytCard from '../../comment/yt-card.vue'
	import ytOpcationItem from '../../comment/yt-opcation-item.vue'
	export default {
		data() {
			return {
				isexamine:true,
				isboss:false,
				ishouse_manage:false
			}
		},
		onLoad() {
			if(uni.getStorageSync('isLogined')){
				this.$refs.uToast.show({
					title: '登录成功',
					type: 'success',
					position:"top"
				})	
			}else{
				this.$refs.uToast.show({
					title: '登录失败',
					type: 'success',
					position:"top"
				})
			}
			
			uniCloud.callFunction({
				name: 'uni-id-cf_mobile',
				data: {
					action:"getUserRole",
					params:{
						userRole:uni.getStorageSync('userRole')[0]
					}
				}
			}).then(({result}) => {
				uni.setStorageSync('role',result.data[0])
				if(uni.getStorageSync('role').permission == "examine"){
					this.isexamine = true
					uni.switchTab({
						url:'../msg/msg'
					})
				}else{
					this.isexamine = false
					if(uni.getStorageSync('role').permission == "admin"){
						this.isboss = true
					}else{
						this.isboss = false
					}
				}
				if(uni.getStorageSync('role').permission == "house_manage"){
					this.ishouse_manage = true
				}else{
					this.ishouse_manage = false
					if(uni.getStorageSync('role').permission == "admin"){
						this.isboss = true
					}else{
						this.isboss = false
					}
				}
			}).catch(err=>{
				console.log(err)
			})
		},
		methods:{
			intoComponent(componentName){
				switch (componentName){
					case "扫码入库":
						uni.scanCode({
						    onlyFromCamera: false,
						    success: function (res) {
								uni.navigateTo({
									url:`../smEnterhouse/smEnterhouse?result=${res.result}`
								})
						    },
							fail() {
								uni.showToast({
									icon:'none',
									title:"扫码失败！"
								})
							}
						});
						break;
					case "手动入库":
						uni.navigateTo({
							url:'../sdEnterhouse/sdEnterhouse'
						})
						break;
					case "出库审批":
						uni.navigateTo({
							url:'../spOuterhouse/spOuterhouse'
						})
						break;
					case "库存查看":
						uni.navigateTo({
							url:'../lookHouse/lookHouse'
						})
						break;
					case "出库记录":
						uni.navigateTo({
							url:'../recordOutHouse/recordOutHouse'
						})
						break;
					case "产品转库":
						uni.navigateTo({
							url:'../houseToHouse/houseToHouse'
						})
						break;
					case "拍照上传":
						uni.navigateTo({
							url:'../takephoto/takephoto'
						})
						break;
					default:
						break;
				}
			}
		},
		components:{
			ytTabbar,
			ytCard,
			ytOpcationItem
		}
	}
</script>

<style>
	.opcation_list{
		margin-bottom: 66.75rpx;
	}
	.content {
		position: absolute;
		top: 0;
		background-color: #EEEEEEFF;
		min-height: 1480rpx;
		width: 100%;
	}
	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
